/*
* Copyright 2011 Andy Lee.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package uk.co.optimisticpanda.remoteweb.command.web

import static uk.co.optimisticpanda.remoteweb.command.web.WebActionType.*

import java.util.List

import uk.co.optimisticpanda.remoteweb.command.Command
import uk.co.optimisticpanda.remoteweb.command.Executable
import uk.co.optimisticpanda.remoteweb.command.Variable

class WebActionsBuilder {

	static Command step(description, Executable executable){
		return new Command(description:description, executable: executable);
	}
	
	static Command step(description, List<Command> children){
		return new Command(description:description, children: children);
	}

	static Variable variable(name, value){
		return new Variable(name:name, value: value);
	}

	static WebExecutable click(id){
		return new WebExecutable(type: click, args: [id: id]);
	}

	static WebExecutable submit(id){
		return new WebExecutable(type: submit, args : [id: id]);
	}

	static WebExecutable go(value){
		return new WebExecutable(type: go, args: [value: value]);
	}

	static WebExecutable type(name, value){
		return new WebExecutable(type: type, args : [name: name, value: value])
	}
	static WebExecutable typeVariable(name, variable){
		return new WebExecutable(type: type, args : [name: name, variable: variable])
	}

	static WebExecutable select(name, value){
		return new WebExecutable(type: select, args :[name: name, value : value])
	}

	static WebExecutable copy(name, fromId){
		return new WebExecutable(type: copy, args:[name: name, fromId: fromId])
	}
	static WebExecutable copyFromName(name, fromName){
		return new WebExecutable(type: copy, args:[name: name, fromName: fromName])
	}
}
